package indiwood.model.dao;

import indiwood.model.AdminVO;
import indiwood.model.MemberVO;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class MemberDAOImpl implements MemberDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	@Override
	public MemberVO login(MemberVO mvo) {
		return sqlSessionTemplate.selectOne("member.login", mvo);
	}
	@Override
	public int register(MemberVO mvo) {
		return sqlSessionTemplate.insert("member.register", mvo);
	}
	@Override
	public int checkEmail(String email) {
		return sqlSessionTemplate.selectOne("member.checkEmail",email);
	}
	@Override
	public MemberVO findMemberByEmail(String email) {
		return sqlSessionTemplate.selectOne("member.findMemberByEmail", email);
	}
	@Override
	public AdminVO loginAdmin(AdminVO avo) {		
		return sqlSessionTemplate.selectOne("member.loginAdmin", avo);
	}
	@Override
	public void outMember(MemberVO mvo) {
		//System.out.println(mvo.getEmail());
		sqlSessionTemplate.delete("member.outMember", mvo);
	}
	@Override
	public void updateMember(MemberVO mvo) {
		sqlSessionTemplate.update("member.updateMember", mvo);		
	}	
}
